import i18n from '@root/i18n';
import { rankData } from '../../../../data';

export const rank: GameEntity = world.querySelector('#排行榜')!;
rank.interactColor = new GameRGBColor(1, 1, 1);
rank.interactHint = '排行榜 / Rank';
rank.interactRadius = 5;
rank.onInteract(async ({ entity }) => {
  entity.player.dialog({
    type: GameDialogType.SELECT,
    content: rankData
      .map((e: GameRankUserData, i: number) => {
        return i18n.t('rank_content', {
          lng: entity.player.lng,
          i: i + 1,
          name: e.name,
          time: e.time,
        });
      })
      .join('\n'),
    title: i18n.t('rank_title', { lng: entity.player.lng }),
    options: ['OK'],
  });
});
rank.enableInteract = true;
